# -*- coding: utf-8 -*-
import os
from liberHook.BaseHook import BaseHook
from liberLibs.dccLibs import Maya, Assembly


class Hook(BaseHook):
    def __init__(self, library, directory, ext, start, end):
        BaseHook.__init__(self, library, directory, ext, start, end)

    def execute(self):
        if not Maya.load_plugin("sceneAssembly.mll"):
            self.append_error("Load sceneAssembly.mll failed.")
            return
        ad_file_name = "%s/%s.ma" % (self.location, self.name)
        if not os.path.isfile(ad_file_name):
            self.append_error("%s is not an exist file." % ad_file_name)
            return
        assembly = Assembly.Assembly()
        assembly.reference_ad("%s_AR" % self.name, ad_file_name)
